package com.company;


import lombok.Data;

/**
 * @date : 2021/11/27 16:07
 * 递归未返回结果的异常
 */

public class P001_RecursiveCall {

    private static int num = 1;

    public static void main(String[] args) {
        System.out.println(method());
    }

    public static Person method() {
        Person person = null;
        try {
            if (num == 1 || num == 2) {
                throw new RuntimeException("第 " + num + " 次失败异常");
            }
            person = new Person();
            person.setName("ABC");
            person.setAge(12);
            System.out.println("成功");
        } catch (Exception e) {
            num++;
            e.printStackTrace();
            //            person = method();
            method();
        }

        return person;
    }

    @Data
    public static class Person {
        private String name;
        private Integer age;
    }
}
